﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using DefineGenerated.DAL;
using System.Xml;
using System.Xml.Linq;
using System.Diagnostics;

namespace DefineGenerated
{
    public partial class Main : Form
    {

        string xmlPath;
        string SavePath;
        DefineHelp m_DefineHelp;
        public Main()
        {
            InitializeComponent();
            m_DefineHelp = new DefineHelp();
        }

        private void Btn_SelXmlPath_Click(object sender, EventArgs e)
        {
            FBD.SelectedPath = @"D:\BaiduNetdiskDownload\DuiLibWorkFlow";
            if (FBD.ShowDialog() == DialogResult.OK)
            {
                xmlPath = FBD.SelectedPath;
                Tb_xmlPath.Text = xmlPath;
            }
        }

        private void Btn_Save_Click(object sender, EventArgs e)
        {
            if (FBD.ShowDialog() == DialogResult.OK)
            {
                SavePath = FBD.SelectedPath;
                Tb_SavePath.Text = SavePath;
            }
        }

        private void Btn_Generated_Click(object sender, EventArgs e)
        {
            if (xmlPath == "") return;
            if (SavePath == "") return;
            List<string> xm = new List<string>();
            IOHelp.Director(xmlPath, xm, ".*?.xml");

            for (int i = 0; i < xm.Count; i++)
            {
                m_DefineHelp.Load(xm[i], SavePath);
                m_DefineHelp.Generated();
            }



            MessageBox.Show("成功");
        }

        private void Btn_Clear_Click(object sender, EventArgs e)
        {
            string[] fs = Directory.EnumerateFiles(SavePath, "*.hpp").ToArray();
            for (int i = 0; i < fs.Length; i++)
            {
                if (File.Exists(fs[i]))
                {
                    File.Delete(fs[i]);
                }
            }
            MessageBox.Show("清除成功");
        }
    }

}
